package com.wxx.shares;

import com.wxx.push.WeChatPush;
import com.wxx.util.CrawlerUtil;
import us.codecraft.webmagic.Page;
import us.codecraft.webmagic.Site;
import us.codecraft.webmagic.processor.PageProcessor;

/**
 * 通过东方财富网获取所有上市公司的名称、股票代码、详情链接
 */
public class SharesProcess implements PageProcessor {

    private SharesDownloader downloader = new SharesDownloader();

    public void process(Page page) {
       // 无需在这处理，在下载器里已经处理
    }

    public Site getSite() {
        return Site.me().setRetryTimes(3).setSleepTime(1000);
    }

    public void start() {
        String startUrl = "http://data.eastmoney.com/zjlx/detail.html";
        CrawlerUtil.genSpider(this, startUrl, downloader).run();

        WeChatPush.pushText("获取所有公司信息任务完成" + downloader.successCount + "页");
    }

    public static void main(String[] args) {
        new SharesProcess().start();
    }

}